<?php echo $javascript->link('treetable.js'); ?>
<?php echo $link->projectLink($project_id, $project_name, __('add_batch', true), '/batches/add'); ?>
<br/><br/>
<h2><?php echo __('batches'); ?></h2>
<div class="largebloc1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php
	$i = 0;
	foreach ($object as $a_batch) { 
	$i++;
	$j = $i + 1;
	$batch = $a_batch['Batch'];
	
	echo $html->tableCells(array('<div id="p'.$i.'" class="tier1">
								<a id="p'.$j.'" href="#" onclick="toggleRows(this); return false;" class="folder" name="p'.$j.'"></a>
								</div>',
								'<strong>'.$link->projectLink($project_id, $project_name, $batch['name'], '/batches/view/'. $batch['id']).'</strong>'),
							'class="odd" id="'.$i.'"', 'class="odd" id="'.$i.'"');
	echo '<tr class="even" id="'.$i.'-1"><td></td><td colspan="4" style="padding-top:7px;padding-bottom:7px;" ><table width="96%" align="center" border="0" cellspacing="1" class="sortable">';
		if ($a_batch['Milestone'] == null) {
	echo '<tr class="tbl2head"><td width="50%">'.__('name', true).'</td><td width="90">'.__('kind', true).'</td><td width="90">'.__('state', true).'</td></tr>';

		foreach($a_batch['Ticket'] as $ticket) {
			if ($ticket['status'] == 'closed')
				echo $html->tableCells(array('<span class="gris">'.$link->projectLink($project_id, $project_name, '#'.$ticket['id'] . ' - ' . $ticket['name'], '/tickets/view/'. $ticket['id']).'</span>',
									'<span class="gris">'.$ticket['kind'].'</span>',	
									'<span class="gris">'.$ticket['status'].'</span>'),
								 'class="odd2"', 'class="even2"');
			else
				echo $html->tableCells(array($link->projectLink($project_id, $project_name, '#'.$ticket['id'] . ' - ' . $ticket['name'], '/tickets/view/'. $ticket['id']),
									$ticket['kind'],	
									$ticket['status']),
								 'class="odd2"', 'class="even2"');
		}
	} else {
		echo $this->renderElement('batches/milestoneTable', array ('milestones' => $a_batch['Milestone'], 'tickets' => $a_batch['Ticket'], 'i' => $i, 'j' => $j));
	}
	echo '</table></td></tr>';
	?>
<?php } ?>
</table>
</div>